﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;

namespace MedicalSelfserviceTerminals.CustomUI
{
    /// <summary>
    /// UCTitleBar.xaml 的交互逻辑
    /// </summary>
    public partial class UCTitleBar : UserControl
    {
        public Action WindowClose { get; set; }
        public int Sec { set; get; }

        DispatcherTimer dt = new DispatcherTimer();

        public UCTitleBar()
        {
            InitializeComponent();
            dt.Interval = TimeSpan.FromSeconds(1);
            dt.Tick += new EventHandler(dt_Tick);//调用函数
            dt.Start();

        }

        private void dt_Tick(object sender, EventArgs e)
        {
            if (Sec == 0)
            {
                dt.Stop();
                //WindowClose();
            }
            this.tbSec.Text = Sec.ToString();
            Sec = Sec - 1;        
        }
        
    }
}
